package com.pets.springboot_petshop.mapper;


import com.pets.springboot_petshop.entity.Membershiptype;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface MembershiptypeMapper {
    //id查询
    @Select("select * from membershiptype where name LIKE CONCAT('%', #{name}, '%');")
    List<Membershiptype> selectMembershiptype(String name);
    //查询所有
    @Select("select * from membershiptype;")
    List<Membershiptype> findAll();
    //添加
    @Insert("insert into membershiptype(name,discount,description,integral,create_time,update_time)values(#{name},#{discount},#{description},#{integral},now(),now());")
    int addMembershiptype(Membershiptype membershiptype);
    //删除
    @Delete("delete from membershiptype where id=#{id};")
    int deleteMembershiptypeById(int id);
    //修改数据
    @Update("UPDATE membershiptype SET name=#{name},discount=#{discount},description=#{description},integral=#{integral},update_time=now() where id= #{id};")
    int updateMembershiptypeById(Membershiptype membershiptype);
}
